using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using pic4uApi.pic4uLoginProxy;

namespace pic4uApi
{
    public class Authentication
    {
        private CookieContainer m_cookies = new CookieContainer();

        internal CookieContainer Cookies
        {
            get { return m_cookies; }
            set { m_cookies = value; }
        }
        
        public bool SignIn(String userName, String password)
        {
            String homePageUrl = Config.Url;

            HttpWebRequest webRequest = HttpWebRequest.Create(homePageUrl) as HttpWebRequest;
            webRequest.CookieContainer = m_cookies;
            WebResponse response = webRequest.GetResponse();
            response.Close();

            authWS authWs = new authWS();
            authWs.Url = String.Format("{0}/services/authWS.asmx", Config.Url);
            authWs.CookieContainer = m_cookies;
       
            return authWs.Signin(userName, password, false);
        }
    }
}
